<!--
 * @Author: JiraiyaChen 979526234@qq.com
 * @Date: 2025-03-12 14:13:33
 * @LastEditors: JiraiyaChen 979526234@qq.com
 * @LastEditTime: 2025-06-05 14:39:05
 * @Description: 批量上传
-->

<template>
  <ClDialog v-bind="$attrs" :title="getTitle" width="1390px">
    <ClBar :loading="loaded">
      <ClUpload
        :init-upload-list="initUploadList"
        :project-id="projectInfo.id"
        :action="action"
        multiple
        @on-success-upload="hasEdited"
        @on-delete="hasEdited"
      />
    </ClBar>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="emit('atClose')">取消</el-button>
        <el-button type="primary" @click="onSure">确定</el-button>
      </span>
    </template>
  </ClDialog>
</template>

<script setup lang="ts">
import { computed, ref } from 'vue'
import { useProjectInfoStore } from '@/store/projectInfo'
const { projectInfo } = useProjectInfoStore()
const action = computed(() => {
  return `${import.meta.env.VITE_APP_BASE_URL_SYH}/cloud/pbgl/supplierFileInfo/uploadBatchFile`
})
const onSure = () => {
  if (editFlag.value) {
    emit('atClose', 'refresh-table')
  } else {
    emit('atClose')
  }
}
// 如果上传、删除过文件，则编辑状态为true，刷新原来表格
const editFlag = ref(false)
const hasEdited = () => {
  editFlag.value = true
}
onMounted(() => {
  getInitUploadList()
})
const loaded = ref(true)
const initUploadList = ref<any[]>([])
const getInitUploadList = async () => {}
const getTitle = computed(() => {
  return props.type
})

interface infoType {
  [props: string]: any
}
const props = defineProps<{ info: infoType; type: string }>()

const emit = defineEmits<{
  (e: 'atClose', str?: string | undefined): void
}>()
</script>

<style scoped lang="scss"></style>
